<?php

use yii\db\Migration;

/**
 * Handles the creation of table `goodes`.
 */
class m190118_072720_create_goodes_table extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $this->createTable('goods', [
            'id' => $this->primaryKey(),
            'status'=>$this->tinyInteger()->notNull()->defaultValue(10)->comment("状态"),
            'type'=>$this->tinyInteger()->notNull()->defaultValue(0)->comment("商品类型"),
            'img'=>$this->integer()->comment("图片"),
            'right'=>$this->integer()->comment("权限（fk）"),
            'title'=>$this->string()->comment("商品名"),
            'description'=>$this->string()->comment("描述"),
            'color'=>$this->string()->comment("颜色"),
            'price'=>$this->integer()->unsigned()->comment("价格"),
            'created_at'=>$this->integer()->comment("创建时间"),
            'updated_at'=>$this->integer()->comment("最后修改时间"),
        ]);
        $this->addForeignKey('fk_goods_image_img','goods','img','image','id','NO ACTION');

    }


    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('goods');
    }
}
